// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from '@/App'
import router from '@/router'
import store from '@/store'
import Vuex from 'vuex'
import elementUI from 'element-ui'
import '@babel/polyfill'
import coordtransform from 'coordtransform'
import i18n from '@/plugins/i18n' // 国际化语言选择
import 'element-ui/lib/theme-chalk/index.css' // element-ui初始的主题色，我们自行定义了
import '@/assets/css/reset.scss'
import 'swiper/dist/css/swiper.css'
import '@/router/permission'
// 引入echarts以及百度地图底图
import echarts from 'echarts'
import 'echarts/extension/bmap/bmap' // 注册window.BMap
import splitPane from 'vue-splitpane'
import elDragDialog from '@/plugins/el-dragDialog'
import VueClipboard from 'vue-clipboard2'
import './assets/icon/iconfont.css'
// import jQuery from 'jquery'
import 'jquery'
//
import VueJsonp from 'vue-jsonp'

import { message } from '@/request/resetMessage'

import SelectTable from './components/select-table'
import Print from '@/plugins/print' //打印页面
import BaiduMap from 'vue-baidu-map'
import { preciseCalculation } from '@/utils/utils'

Vue.component('el-select-table', SelectTable)

Vue.use(Print)
Vue.use(VueClipboard)
Vue.use(VueJsonp) //解决跨域

// Window.jQuery = jQuery

// window.addEventListener('resize', () => {
//   //
//   //
//   document.getElementsByTagName('html')[0].style.zoom = document.documentElement.clientWidth / 1920
// })
// document.getElementsByTagName('html')[0].style.zoom = document.documentElement.clientWidth / 1920
Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: window._$api.baidumapKey
})
// 开发环境开启devtools
Vue.config.devtools = process.env.NODE_ENV === 'development'

// 生产环境关闭警告域提示
Vue.config.silent = process.env.NODE_ENV === 'production'

// 设置js的计算
preciseCalculation()

// 根据不同的环境加载不同的链接  优先加载 config.js 文件下的链接
if (CUST_URL == '' || CUST_URL == null || CUST_URL == undefined) {
  api.BASEURL = process.env.VUE_APP_API_BASEURL
  api.PRDURL = process.env.VUE_APP_API_BASEURL
  api.IMAGE_PREFIX = process.env.VUE_APP_API_BASEURL + '/'
} else {
  api.BASEURL = CUST_URL
  api.PRDURL = CUST_URL
  api.IMAGE_PREFIX = CUST_URL + '/'
}

const DIALOG_MODE = {
  ADD: '新增',
  EDIT: '编辑',
  VIEW: '详情'
}

Vue.config.productionTip = false

// 全局注册echarts，可以通过this.$echarts使用
Object.defineProperties(Vue.prototype, {
  $echarts: {
    get: () => echarts
  },
  $Y: {
    get: () => 'Y'
  },
  $N: {
    get: () => 'N'
  },
  $homeURL: {
    get: () =>
      '/layout/iframe?url=' +
      window.location.origin +
      '#/home&title=router.home'
  },
  coordtransform: {
    get: () => coordtransform
  },
  DIALOG_MODE: {
    get: () => DIALOG_MODE
  }
})

Vue.use(elementUI)
Vue.use(Vuex)
// 注册可拖动弹窗插件（指令）
Vue.use(elDragDialog)

// 注册可拖拽弹窗插件（指令）
// Vue.use(dialogDrag)

Vue.component('split-pane', splitPane)
router.afterEach(() => {
  window.scrollTo(0, 0)
})

window._$store = store

// window._$message = elementUI.Message
window._$message = message

;(async function() {
  // 初始化 mock 数据
  // 如果不需要注释或移除即可
  //await (await import('@/mock')).initMock()

  new Vue({
    el: '#app',
    i18n, // 使用 i18n 插件
    router,
    store: store,
    components: { App },
    template: '<App/>'
  })
})()
